/*
 *  ssl.h - SSL management functions
 *  Copyright (c) 2005 Derek Ingrouville (dergro@users.sourceforge.net)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef _SSL_H
#define _SSL_H

#include <glib.h>
/*#include <config.h>*/

#include "socket.h"

#define HAVE_OPENSSL

#ifdef HAVE_OPENSSL

#include <openssl/ssl.h>

typedef struct _SSLSocket
{
    Socket *socket;
    SSL *ssl;
    SSL_CTX *ctx;
    gboolean connected;
} SSLSocket;

#elif HAVE_GNUTLS

#include <gnutls/gnutls.h>
#include <gnutls/gnutls.h>

typedef struct _SSLSocket
{
    Socket *socket;
    gnutls_session session;
    gnutls_certificate_credentials xcred;
    gboolean connected;
} SSLSocket;

#endif

SSLSocket *ssl_connect (const char *addr, int port);
void ssl_close (SSLSocket *sslsock);
int ssl_read (SSLSocket *sslsock, char *buffer, unsigned int size);
char *ssl_recv_all (SSLSocket *sslsock);
int ssl_write (SSLSocket *sslsock, const char *buffer, int len);
gboolean ssl_data_available (SSLSocket *sslsock);

#endif /* _SSL_H */
